﻿using System.Security.Claims;
using System.Threading;
using Abp.Runtime.Session;
using Microsoft.AspNetCore.Http;

namespace Hicap.AuthorizationServer.Core.Common
{
    public class HicapPrincipalAccessor : DefaultPrincipalAccessor, IPrincipalAccessor
    {
        public override ClaimsPrincipal Principal => _contextAccessor.HttpContext?.User ?? base.Principal as ClaimsPrincipal;

        private readonly IHttpContextAccessor _contextAccessor;

        public HicapPrincipalAccessor(IHttpContextAccessor contextAccessor)
        {
            _contextAccessor = contextAccessor;
        }
    }
}